<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ page import="java.net.URL"%>
<%@ page import="org.jdom.Document"%>
<%@ page import="org.jdom.Element"%>
<%@ page import="org.jdom.input.SAXBuilder"%>
<%@ page import="org.xml.sax.InputSource"%>
<%@ page import="java.util.List"%>

<%
 //JDOM XML Parsing
 List list = null;

 
 try {
  SAXBuilder parser = new SAXBuilder();
  parser.setValidation(false);
  parser.setIgnoringElementContentWhitespace(true);
  File resourceFile = new File(application.getRealPath("/")+request.getContextPath()+"ets/Shop/test1.xml");
  //URL url = resourceFile.toURI().toURL();
  URL url = new URL("http://openapi.naver.com/search?key=e74f4e476ae4695a5098fe088812a820&query=%EB%85%B8%ED%8A%B8%EB%B6%81&display=5&start=1&target=shop&sort=sim");
  InputSource is = new InputSource(url.openStream());
  Document doc = parser.build(is);   

  Element root = doc.getRootElement(); 
  Element channel = root.getChild("channel");  
  
  list = channel.getChildren("item"); // List Object Operation

 } catch(Exception e) {
 
  e.getStackTrace();
  
 }
%>



<%@page import="java.io.File"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JDOM XML</title>
</head>
<body>
 
<UL>
<%
    Element el = (Element) list.get(0);
%>
 <LI><a href="<%=el.getChildText("link") %>" target="_news"><%=el.getChildText("title") %><br/>
     -최저가격: <%=el.getChildText("lprice")%><br/>
	 -최고가격: <%=el.getChildText("hprice")%><br/>
	<img src="<%=el.getChildText("image")%>"></a></LI>
 
</UL>
</body>
</html>
